package com.ll.datedemo;

import java.time.Instant;
import java.util.Date;

/**
 * @author 刘龙
 * @version 1.0
 */
public class InstantDemo {
    public static void main(String[] args) {
        // 通过静态方法now, 获取表示当前时间戳的对象
        Instant instant = Instant.now();
        // 2021-03-24T03:46:34.578181100Z
        System.out.println(instant);

        Date date = Date.from(instant);
        // Wed Mar 24 11:48:50 CST 2021
        System.out.println(date);

        // Date => Instant
        Instant instant1 = date.toInstant();
        // 2021-03-24T03:49:31.380Z
        System.out.println(instant1);
    }
}
